package com.jk.controller;

import com.jk.service.AuthOrgInfoService;
import com.jk.vo.AuthOrgInfo;
import com.jk.vo.AuthUserIdcard;
import com.jk.vo.Employee;
import com.jk.vo.WorkOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * Created by ${user} on ${data}.
 */
@RestController
@RequestMapping("AuthOrgInfo")
public class AuthOrgInfoController {
    @Autowired
    private AuthOrgInfoService authOrgInfoService;

    @GetMapping("SelectAuthOrgInfo")
    public List<Map> SelectAuthOrgInfo(AuthOrgInfo authOrgInfo){
        List<Map> authOrgList = authOrgInfoService.SelectAuthOrgInfo(authOrgInfo);
        System.out.println("----------------------------------");
        return authOrgList;
    }
    @GetMapping(value="queryMenubyIds")
    public ModelAndView queryMenubyIds( String id){
        ModelAndView mc=new ModelAndView("/systemList/toupdateOrg.jsp");
        AuthOrgInfo orginfo =authOrgInfoService.updateOrg(id);
        mc.addObject("u", orginfo);
        return mc;
    }
    @PutMapping("UpdateAuthOrgInfo")
    public  int UpdateAuthOrgInfo(AuthOrgInfo authOrgInfo,HttpSession session ,String userid) {
        Employee employeelog = (Employee)session.getAttribute("employeelog");
        WorkOrder workOrder = new WorkOrder();
        if (employeelog != null) {
            workOrder.setWmployeeId(employeelog.getEmployeeId());
        } else {
            workOrder.setWmployeeId("1");
        }
        workOrder.setUserId(userid);
        System.out.println(workOrder);
        return authOrgInfoService.UpdateAuthOrgInfo(authOrgInfo, workOrder);

    }
}
